//
//  BaseViewController.m
//  WBBaseProject
//
//  Created by 吴斌 on 2017/6/27.
//  Copyright © 2017年 吴斌. All rights reserved.
//

#import "BaseViewController.h"
#import "WBKit.h"

@interface BaseViewController ()

@property (nonatomic,strong) WBLoadingHubView *loadingHubView;

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    //导航栏添加返回按钮
    [self addLeftBtn];
}

- (void)addLeftBtn{
    //返回按钮
    self.wb_leftButton = [Factory backButton:self];
    [self.wb_leftButton addTarget:self action:@selector(clickBack:) forControlEvents:UIControlEventTouchUpInside];    
}

- (void)clickBack:(id)sender{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}

/*!
 *  三个球 自定义加载动画
 *
 *  @param isShow yes:显示，no:隐藏
 */
- (void)wb_showBallLoadingView:(BOOL)isShow
{
    if (isShow) {
        _loadingHubView = [[WBLoadingHubView alloc] initWithFrame:CGRectMake(0, 0, 150, 150)];
        _loadingHubView.center = self.view.center;
        _loadingHubView.ballColor = [UIColor purpleColor];
        [self.view addSubview:_loadingHubView];
        [_loadingHubView wb_showHub];
    }
    else
    {
        [_loadingHubView wb_dismissHub];
    }
}

/*!
 *  开启樱花动画
 */
- (void)wb_starYingHuaCoreAnimation
{
    // =================== 樱花飘落 ====================
    CAEmitterLayer * snowEmitterLayer = [CAEmitterLayer layer];
    snowEmitterLayer.emitterPosition = CGPointMake(100, -30);
    snowEmitterLayer.emitterSize = CGSizeMake(self.view.bounds.size.width * 2, 0);
    snowEmitterLayer.emitterMode = kCAEmitterLayerOutline;
    snowEmitterLayer.emitterShape = kCAEmitterLayerLine;
    //    snowEmitterLayer.renderMode = kCAEmitterLayerAdditive;
    
    CAEmitterCell * snowCell = [CAEmitterCell emitterCell];
    
    snowCell.contents = (__bridge id)[UIImage imageNamed:@"樱花瓣2.jpg"].CGImage;
    
    // 花瓣缩放比例
    snowCell.scale = 0.02;
    snowCell.scaleRange = 0.5;
    
    // 每秒产生的花瓣数量
    snowCell.birthRate = 10;
    snowCell.lifetime = 80;
    
    // 每秒花瓣变透明的速度
    snowCell.alphaSpeed = -0.01;
    
    // 秒速“五”厘米～～
    snowCell.velocity = 40;
    snowCell.velocityRange = 60;
    
    // 花瓣掉落的角度范围
    snowCell.emissionRange = M_PI;
    
    // 花瓣旋转的速度
    snowCell.spin = M_PI_4;
    
    // 每个cell的颜色
    //    snowCell.color = [[UIColor redColor] CGColor];
    
    // 阴影的 不透明 度
    snowEmitterLayer.shadowOpacity = 1;
    // 阴影化开的程度（就像墨水滴在宣纸上化开那样）
    snowEmitterLayer.shadowRadius = 8;
    // 阴影的偏移量
    snowEmitterLayer.shadowOffset = CGSizeMake(3, 3);
    // 阴影的颜色
    snowEmitterLayer.shadowColor = [[UIColor whiteColor] CGColor];
    
    snowEmitterLayer.emitterCells = [NSArray arrayWithObject:snowCell];
    [self.view.layer addSublayer:snowEmitterLayer];
}


@end
